class CreateBrowseRecords < ActiveRecord::Migration
  def self.up
    create_table :browse_records do |t|
      t.integer :valleyer_id,
        :article_id,
        :reship_id,
        :album_id,
        :photo_id,
        :meet_id,
        :browser_id
      t.timestamps
    end
    add_column :articles, :browse_records_count, :integer, :default => 0
    add_column :reships, :browse_records_count, :integer, :default => 0
    add_column :albums, :browse_records_count, :integer, :default => 0
    add_column :photos, :browse_records_count, :integer, :default => 0
    add_column :valleyers, :browse_records_count, :integer, :default => 0
    add_column :meets, :browse_records_count, :integer, :default => 0
  end

  def self.down
    drop_table :browse_records
    remove_column :articles, :browse_records
    remove_column :reships, :browse_records
    remove_column :albums, :browse_records
    remove_column :photos, :browse_records
    remove_column :valleyers, :browse_records
    remove_column :meets, :browse_records
  end
end
